<?php
/**
 * | ---------------------------------------------------------------------------------------------------
 * | Author：johnxu <fsyzxz@163.com>.
 * | ---------------------------------------------------------------------------------------------------
 * | Home: https://www.johnxu.net.
 * | ---------------------------------------------------------------------------------------------------
 * | Data: 2019-03-17
 * | ---------------------------------------------------------------------------------------------------
 * | Desc: 后台以接口的方式进行
 * | ---------------------------------------------------------------------------------------------------
 */

namespace app\service\controller;

use johnxu\tool\Api;
use think\Db;

class Index extends Api
{
    protected $tableUser = 'users';

    /**
     * 客服登陆后的操作：1初始化socket服务，更改登录状态；2修改头像，删除不该返回的字段
     *
     * @param $users
     */
    public function authorizationSuccess( &$users )
    {
        // 删除所有没用的登录token
        Db::name( $this->tableToken )->where( [ 'status' => 0, 'user_id' => $users['id'] ] );
        $users['avatar'] = 'http://custom.service.local.cn' . $users['avatar'];
    }
}